﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace VCDIFF.Tools
{
    public class VCDIFFTools
    {
        /// <summary>
        /// Gets the range of a data table.
        /// </summary>
        /// <param name="data">The data table from which we get the range.</param>
        /// <param name="beginning">Beginning index of the range.</param>
        /// <param name="end">End index of the range</param>
        /// <returns>The range of a data table.</returns>
        public static byte[] GetRange(byte[] data, UInt64 beginning, UInt64 end)
        {
            byte[] range = new byte[end - beginning + 1];
            UInt64 index = 0;

            for (UInt64 i = beginning; i <= end; i++)
            {
                range[index] = data[beginning + index];
                index++;
            }

            return range;
        }

        /// <summary>
        /// Gets the range of a data table.
        /// </summary>
        /// <param name="data">he data table from which we get the range.</param>
        /// <param name="beginning">Beginning index of the range.</param>
        /// <returns>The range of a data table.</returns>
        public static byte[] GetRange(byte[] data, UInt64 beginning)
        {
            byte[] range = new byte[(UInt64)data.Length - beginning];
            UInt64 index = 0;

            for (UInt64 i = beginning; i < (UInt64)data.Length; i++)
            {
                range[index] = data[i];
                index++;
            }

            return range;
        }
    }
}
